package net.lb.io.json;

import java.util.HashMap;

public class JsonObject extends HashMap<String, Object> implements Json
{
    private static final long serialVersionUID = 1L;
    
    public String toString()
    {
        return JsonUtil.toJsonString(this);
    }
    
    public JsonObject getJsonObject(String key)
    {
        return (JsonObject) get(key);
    }
    
    public JsonArray getJsonArray(String key)
    {
        return (JsonArray) get(key);
    }
    
    public String getString(String key)
    {
        return (String) get(key);
    }
    
    public Long getLong(String key)
    {
        return ((Long) get(key));
    }
    
    public Integer getInteger(String key)
    {
        Number number = (Number) get(key);
        if (number != null)
        {
            return number.intValue();
        }
        else
        {
            return null;
        }
    }
    
    public Double getDouble(String key)
    {
        return ((Double) get(key));
    }
    
    public Boolean getBoolean(String key)
    {
        return (Boolean) get(key);
    }
    
}
